/**
 * 汉字统计
 */
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    char s[500];
    int n;
    cin >> n;
    getchar();
    while (n--)
    {
        cin.getline(s, 500);
        int nRet = 0;
        int len = strlen(s);
        for (int i = 0; i < len; ++i) 
        {
            if (s[i] < 0)
            {
                ++nRet;
            }
        }
        cout << nRet / 2 << endl;
    }
    return 0;
}